import { GTable, SchemaFieldComponents } from 'geminis-react';
import './edit.less';
import { EditableProductBatchSelect } from '@/pages/basic/productBatch/components/EditableProductBatchSelect';
import { TransporterSelect } from '@/pages/basic/transporter/components/RouteSelect';
import { RouteSelect } from '@/pages/basic/route/components/RouteSelect';

SchemaFieldComponents['EditableProductBatchSelect'] = EditableProductBatchSelect;
SchemaFieldComponents['TransporterSelect'] = TransporterSelect;
SchemaFieldComponents['RouteSelect'] = RouteSelect;

export default () => {
  const schema = {
    headerTitle: '采购方案',
    data: {
      url: '/api/warehouse/purchase/purchase',
      include: ['routes'],
      sort: 'planTime:desc',
    },
    action: {
      toolbar: {
        add: {
          form: {
            schemaPath: '/warehouse-pc/schema/purchase/plan/edit.json',
            schema: {
              data: {
                include: ['routes', 'details'],
              },
            },
            onSubmitting: (value: any) => {
              value.state = 10;
            },
          },
        },
      },
      row: {
        delete: true,
      },
    },
  };

  return (
    <GTable
      schemaPath="/warehouse-pc/schema/purchase/plan/table.json"
      schema={schema}
    />
  );
}
;
